//
//  main.cpp
//  api-server
//
//  Created by Peter Emil Jensen on 26/08/2012.
//  Copyright (c) 2012 Peter Emil Jensen. All rights reserved.
//

#include "main.h"

int main(int argc, char* argv[])
{
    try
    {
        if (argc != 4)
        {
            std::cerr << "Usage: http_server <address> <port> <threads>\n";
            std::cerr << "  For IPv4, try:\n";
            std::cerr << "    receiver 0.0.0.0 80 1\n";
            
            argv[1] = "0.0.0.0";
            argv[2] = "80";
            argv[3] = "2";
        }
        
        std::size_t num_threads = boost::lexical_cast<std::size_t>(argv[3]);
        server s(argv[1], argv[2], num_threads);
        
        s.run();
    }
    catch (std::exception& e)
    {
        std::cerr << "exception: " << e.what() << "\n";
    }
    
    std::cout << "Closing..." << std::endl;
    
    return 0;
}